import { tagMapOption } from "../hooks";

export const mapPMJobBasicInfoData = (
  data: Record<string, any> | null
): Array<{ key: string; label: string; value: string | number; text?: string; span?: number }> => {
  if (!data) return [];

  const {
    jobNo = "",
    title = "",
    planNo = "",
    areaId = "",
    planStartTime = "",
    planEndTime = "",
    estPmHours = "",
    jobStartTime = "",
    jobEndTime = "",
    actPmHours = "",
    pmHours = "",
    planDetail = {}
  } = data;

  const d_1 = {
    key: "jobNo",
    label: "Job No",
    value: jobNo
  };
  const d_2 = {
    key: "title",
    label: "Job Title",
    value: title
  };
  const d_3 = {
    key: "planNo",
    label: "Plan No",
    value: planNo
  };
  const d_4 = {
    key: "areaId",
    label: "Area",
    value: areaId
  };
  const d_5 = {
    key: "planStartTime",
    label: "Plan Start Time",
    value: planStartTime
  };
  const d_6 = {
    key: "planEndTime",
    label: "Plan End Time",
    value: planEndTime
  };
  const d_7 = {
    key: "estPmHours",
    label: "Est Pm Hours",
    value: estPmHours
  };
  const d_8 = {
    key: "jobStartTime",
    label: "Job Start Time",
    value: jobStartTime
  };
  const d_9 = {
    key: "jobEndTime",
    label: "Job End Time",
    value: jobEndTime
  };
  const d_10 = {
    key: "actPmHours",
    label: "Act Pm Hours",
    value: actPmHours
  };
  const d_11 = {
    key: "pmHours",
    label: "Pm Hours",
    value: pmHours
  };

  if (!planDetail) {
    return [d_1, d_2, d_3, d_4, d_5, d_6, d_7, d_8, d_9, d_10, d_11];
  }

  const {
    category = "",
    triggerCode = "",
    interval = "",
    offsetUnit = "",
    triggerPmSeason = "",
    earlyOffset = "",
    lateOffset = "",
    dueDateTime = "",
    earlyDateTime = "",
    lateDateTime = ""
  } = planDetail;

  const d_12 = {
    key: "category",
    label: "Category",
    value: category
  };
  const d_13 = {
    key: "triggerCode",
    label: "Trigger Code",
    value: triggerCode
  };
  const d_14 = {
    key: "interval",
    label: "Interval",
    value: interval
  };
  const d_15 = {
    key: "offsetUnit",
    label: "Offset Unit",
    value: offsetUnit
  };
  const d_16 = {
    key: "triggerPmSeason",
    label: "Trigger Pm Season",
    value: triggerPmSeason
  };
  const d_17 = {
    key: "earlyOffset",
    label: "Early Offset",
    value: earlyOffset
  };
  const d_18 = {
    key: "lateOffset",
    label: "Late Offset",
    value: lateOffset
  };
  const d_19 = {
    key: "dueDateTime",
    label: "Due Date Time",
    value: dueDateTime
  };
  const d_20 = {
    key: "earlyDateTime",
    label: "Early Date Time",
    value: earlyDateTime
  };
  const d_21 = {
    key: "lateDateTime",
    label: "Late Date Time",
    value: lateDateTime
  };

  return [d_1, d_2, d_3, d_4, d_5, d_6, d_7, d_8, d_9, d_10, d_11, d_12, d_13, d_14, d_15, d_16, d_17, d_18, d_19, d_20, d_21];
};

export const tableCloumns: Array<CommonTable.TableCloumnsType> = [
  {
    label: "内容",
    prop: "message",
    width: 300
  },
  {
    label: "评论人",
    prop: "commentatorByName",
    width: 150
  },
  {
    label: "时间",
    prop: "commentatorTime",
    width: 180
  }
];

export const tableCloumns2: Array<CommonTable.TableCloumnsType> = [
  {
    label: "EQP ID",
    prop: "eqpId",
    width: 100
  },
  {
    label: "Plan No",
    prop: "planNo",
    width: 150
  },
  {
    label: "Plan Title",
    prop: "planTitle",
    width: 120
  },
  {
    label: "Category",
    prop: "category",
    width: 120
  },
  {
    label: "Plan Status",
    prop: "planStatus", // 1、厂务  PROCESSING  INACTIVE  WAITING    2、fab机台  processing  inActive  waiting
    width: 120,
    tagMapOption,
    defaultTagValue: "PROCESSING",
    mapRow: ({ row: { planStatus: value = "", planStatusName: label = "" } }: any) => ({ value, label })
  },
  {
    label: "Trigger Code",
    prop: "triggerCode",
    width: 120
  },
  {
    label: "Early Date",
    prop: "earlyDateTime",
    width: 120
  },
  {
    label: "Due Date",
    prop: "dueDateTime",
    width: 120
  },
  {
    label: "Late Date",
    prop: "lateDateTime",
    width: 120
  }
];
